package com.mushroom_street.product.controller;

import com.mushroom_street.product.dto.ProductDto;
import com.mushroom_street.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping(value = "/product")
public class ProductController {
    @Resource
    private ProductService productService;

    @GetMapping(value = "/products")
    public List<ProductDto> loadProductList(){
        return productService.loadProductList();

    }
    @GetMapping(value = "/products/{id}")
    public ProductDto loadProductById(@PathVariable String id){
        ProductDto productDto = productService.loadProductById(id);
        return productDto;

    }

}
